#pragma once

#include <bofcl_eclic_clicint_r.h>

// clicintip寄存器的定义
typedef struct {
	u8_s IP : 1;
	u8_s : 7;
} eclic_clicintip_s;

_Static_assert(sizeof(eclic_clicintip_s) == 1,
	       "Struct eclic_clicintip_s defined error!");

// clicintie寄存器的定义
typedef struct {
	u8_s IE : 1;
	u8_s : 7;
} eclic_clicintie_s;

_Static_assert(sizeof(eclic_clicintie_s) == 1,
	       "Struct eclic_clicintie_s defined error!");

// clicintattr寄存器的定义
typedef struct {
	u8_s shv : 1;
	u8_s trig : 2;
	u8_s : 5;
} eclic_clicintattr_s;

_Static_assert(sizeof(eclic_clicintattr_s) == 1,
	       "Struct eclic_clicintattr_s defined error!");

// ECLIC中断属性项定义
typedef struct {
	eclic_clicintip_s clicintip;
	eclic_clicintie_s clicintie;
	eclic_clicintattr_s clicintattr;
	u8_s clicintctl;
} __attribute__((aligned(4))) eclic_clicint_s;

_Static_assert(sizeof(eclic_clicint_s) == 4,
	       "Struct eclic_clicint_s defined error!");

// 设置clicint数组第i个元素（中断属性）的值
static inline void eclic_wreg_clicint_s_by_q(u32_s eclic_q, u32_s th_r,
					     eclic_clicint_s clicint) {
	union {
		eclic_clicint_s c;
		u32_s u;
	} cu = {
		.c = clicint,
	};
	eclic_wreg_clicint_by_q(eclic_q, th_r, cu.u);
}
